package other;

import java.util.LinkedHashMap;
import java.util.Map;

// 利用LinkedHashMap实现
public class Lru extends LinkedHashMap {

    private int cacheSize;

    public Lru(int initialCapacity, int cacheSize) {
        super(initialCapacity);
        this.cacheSize = cacheSize;
    }

    protected boolean removeEldestEntry(Map.Entry eldest) {
        return this.size() >= cacheSize;
    }
}
